package com.wms.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;


@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "Goods对象", description = "")
public class Goods implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "货名")
    private String name;

    @ApiModelProperty(value = "仓库")
    private Integer storage;

    @ApiModelProperty(value = "分类")
    @TableField("goodsType")
    private Integer goodstype;

    @ApiModelProperty(value = "数量")
    private Integer count;

    @ApiModelProperty(value = "备注")
    private String remark;

//    private Goods postHTML(String strURL,String postDataStr){
//        Goods comProduct = new Goods();
//        OutputStreamWriter out = null;
//        BufferedReader in = null;
//        String sTotalString = "";
//        try {
//            URL url = new URL(strURL);
//            URLConnection connection = url.openConnection();
//            connection.setRequestProperty("accept", "*/*");
//            connection.setRequestProperty("connection", "Keep-Alive");
//            connection.setRequestProperty("user-agent",
//                    "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
//            // 发送POST请求必须设置如下两行
//            connection.setDoOutput(true);
//            connection.setDoInput(true);
//            //设置utf-8编码
//            out = new OutputStreamWriter(connection
//                    .getOutputStream(),"utf-8");
//            out.write(postDataStr); //post的关键所在！
//            // remember to clean up
//            out.flush();
//            // 一旦发送成功，用以下方法就可以得到服务器的回应：
//            String sCurrentLine;
//            sCurrentLine = "";
//            InputStream l_urlStream;
//            l_urlStream = connection.getInputStream();
//            //设置utf-8编码
//            BufferedReader l_reader = new BufferedReader(new InputStreamReader(
//                    l_urlStream,"utf-8"));
//            while ((sCurrentLine = l_reader.readLine()) != null) {
//                sTotalString += sCurrentLine + "\r\n";
//            }
//            Document doc = Jsoup.parse(sTotalString);
//            Elements trs = (Elements) doc.select("table").select("tr");
//            for(int i = 0;i<trs.size();i++){
//                Elements tds = trs.get(i).select("td");
//                for(int j = 0;j<tds.size();j++){
//                    if(i==12) {
//                        comProduct.setBarCode(tds.get(0).text());
//                        comProduct.setName(tds.get(1).text());
//                        Integer id = comProductClassDao.getProductClassByName(tds.get(2).text());
//                        comProduct.setClassId(comProductClassDao.getProductClassByName(tds.get(2).text()));
//                        comProduct.setNo(tds.get(3).text());
//                        comProduct.setInfo(tds.get(6).text());
//                    }
//                }
//            }
//        } catch (Exception e) {
//            // TODO: handle exception
//            System.out.println("发送 POST 请求出现异常！"+e);
//            e.printStackTrace();
//        }
//        finally{
//            try{
//                if(out!=null){
//                    out.close();
//                }
//                if(in!=null){
//                    in.close();
//                }
//            }
//            catch(IOException ex){
//                ex.printStackTrace();
//            }
//        }
//        return comProduct;
//    }
//    public Goods AnalyzeProductInfo(String Url) {
//        Map<String, String> params = new HashMap<>();
////将unitCaCode解码
//        params.put("code", UrlDeCodeUtils.MyUrlDeCode(unitCaCode));
//
//        JSONObject jsonObject = JSONObject.parseObject(HttpClientUtil.HttpPost("http","接口url", params));
//        jsonRootBean = new JsonRootBean();
////将JSON转换成实体类 返回实体类
//        jsonRootBean = JSONObject.toJavaObject(jsonObject, JsonRootBean.class);
//        return JsonRootBean;
//    }

}
